--[[
	  Project name: 3friends ENGiNE
	  Module name: cmd's module
	  Authors/Contributors: V0ID
--]]

--Arrays
	local cmd = {}
	cmd.__index = cmd
	cmd.array = {} --Where is handlers? Here o_O

--Functions
function cmd.addHandler(cmdd, func)
	if cmdd and func and cmdd ~= nil and func ~= nil then
		for k,v in ipairs(cmd.array) do
			if v.cmd == cmdd then
				return false	--One handler per command
			end
		end
			table.insert(cmd.array,{cmd = cmdd, fnct = func})
	else
		return false
	end
end

function cmd.removeHandler(cmdd, func)
	if cmdd and func and cmdd ~= nil and func ~= nil then
		for k,v in ipairs(cmd.array) do
			if v.cmd == cmdd then
				table.remove(cmd.array,k)
					return true
			end
		end
	else
		return false
	end
end

function cmd.execHandler(cmdd, playerid, params)
	if cmdd and playerid and params and cmdd ~= nil and playerid ~= nil then
			for k,v in ipairs(cmd.array)
				if v.cmd == cmdd then
					v.fnct(playerid, params)
						return true
				end
			end
	else
		return false
	end
end

--End